var incomeChart = ring.create({
    constructor: function(plot) 
    {
        this.plot1 = plot;
    },
    plotChart: function(id, data)
    {
        var that = this;
        if (that.plot1) {
            that.plot1.destroy();
        }
        
        that.plot1 = $.jqplot(id, [data], {
          series:[{renderer:$.jqplot.BarRenderer}],
          axesDefaults: {
              tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
              tickOptions: {
                fontSize: '10pt'
              }
          },
          axes: {
            xaxis: {
              renderer: $.jqplot.CategoryAxisRenderer
            }
          }
        });
    },
    refresh: function(id, url_data) {
        var dateTo   = $('#select-month-to').val(); 
        var dateFrom = $('#select-month-from').val();   
        
        var that = this;
        
        $.ajax({
            url: url_data, 
            data: { date_to : dateTo, date_from : dateFrom},
            async: false, 
            success: function(result) 
            {
                 that.plotChart(id, result);
            }
        });
    }
});
